package com.zb.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zb.dto.UserDTO;
import com.zb.entity.TbUserModel;
import com.zb.service.TbUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName TbUserController
 * @Description 用户表控制器
 * @Author xm
 * @Date 2024/11/11 15:39
 **/
@RestController
@RequestMapping("/tb-user-model")
public class TbUserController {

    @Autowired
    public TbUserService tbUserModelService;


    @GetMapping("/info/{username}")
    public UserDTO getUserInfo(@PathVariable("username") String username) {
        LambdaQueryWrapper<TbUserModel> qw = new LambdaQueryWrapper<>();
        qw.eq(TbUserModel::getUsername, username);
        TbUserModel one = tbUserModelService.getOne(qw);
        UserDTO userDTO = new UserDTO();
        BeanUtils.copyProperties(one, userDTO);
        return userDTO;
    }
}
